{% load i18n %}

<div class="inline-group inline-tabular{% if inline_admin_formset.opts.sortable %} sortable{% endif %}{% if inline_admin_formset.opts.classes %} {{ inline_admin_formset.opts.classes|join:" " }}{% endif %}"
     name="inlinegrouptabular">
    <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
    <ul class="inline-item-tools">
        {% if inline_admin_formset.opts.allow_add %}
            <li><a href="javascript://" class="addhandler" title="{% trans 'Add Item' %}"></a></li>{% endif %}
    </ul>
    {{ inline_admin_formset.formset.management_form }}
    {{ inline_admin_formset.formset.non_form_errors }}
    {{ inline_admin_formset.opts.model.opts.order_with_respect_to }}
    <div class="items"> <!-- table, sortable container -->
        <div class="legend"> <!-- table header -->
            {% for field in inline_admin_formset.fields %}
                {% if not field.is_hidden %}
                    <div class="form-cell {{ field.label|lower }}">{{ field.label|capfirst }}</div>
                {% endif %}
            {% endfor %}
            <div class="form-cell">&nbsp;</div>
        </div>
        {% for inline_admin_form in inline_admin_formset %}
            <div class="inline-related{% if inline_admin_form.original or inline_admin_form.show_url %} has_original{% endif %}">
                <!-- tbody, sortable items -->
                <!-- errors -->
                {% if inline_admin_form.form.non_field_errors %}
                    <div>{{ inline_admin_form.form.non_field_errors }}</div>
                {% endif %}
                <h3 style="display: none;"><b>{{ inline_admin_formset.opts.verbose_name|title }}
                    #{{ forloop.counter }}</b>&nbsp;&nbsp;{% if inline_admin_form.original %}
                    {{ inline_admin_form.original }}{% endif %}</h3>
                <!-- hidden fields -->
                {% spaceless %}
                    {% for fieldset in inline_admin_form %}
                        {% for line in fieldset %}
                            {% for field in line %}
                                {% if field.is_hidden %} {{ field.field }} {% endif %}
                            {% endfor %}
                        {% endfor %}
                    {% endfor %}
                {% endspaceless %}
                <!-- fieldsets -->
                <div class="fieldset module"> <!-- table-row -->
                    {% for fieldset in inline_admin_form %}
                        {% for line in fieldset %}
                            {% for field in line %}
                                <div class="item form-cell {{ field.field.name }} {% if field.field.errors %} error{% endif %}">
                                    {% if field.is_readonly %}
                                        {{ field.contents }}
                                    {% else %}
                                        {{ field.field }}&nbsp;
                                    {% endif %}
                                    {% if field.field.help_text %}
                                        <p class="help" style="padding-top: 5px">{{ field.field.help_text|safe }}</p>
                                    {% endif %}
                                    {{ field.field.errors.as_ul }}
                                </div>
                            {% endfor %}
                        {% endfor %}
                    {% endfor %}
                    <!-- delete/link/sort -->
                    <div class="item form-cell inline-item-tools">
                        <ul class="inline-item-tools">
                            {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}
                                <li>{{ inline_admin_form.deletion_field.field }}<a href="javascript://"
                                                                                   class="deletelink"
                                                                                   title="{% trans 'Delete Item' %}"></a>
                                </li>{% endif %}
                            {% if inline_admin_form.show_url %}
                                <li>
                                    <a href="../../../r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/"
                                       class="viewsitelink" title="{% trans 'View on Site' %}"></a></li>{% endif %}
                            {% comment %}{% if inline_admin_formset.opts.sortable %} <li><a href="javascript://" class="draghandler" title="{% trans 'Move Item' %}"></a></li>{% endif %}{% endcomment %}
                        </ul>
                    </div>
                    {{ inline_admin_form.fk_field.field }}
                    {{ inline_admin_form.pk_field.field }}
                </div>
            </div>
        {% endfor %}
    </div>
</div>

<div class="sortablehelper">
    <h3><b>&nbsp;</b></h3>
</div>

